﻿using System.ConfigCenter.Server.Models;

using GCC.Container.Abstracts;

namespace System.ConfigCenter.Server
{
    public class GCCEntrance : AbsEntrance
    {

        public override bool IsRelease()
        {
#if DEBUG
            return false;
#else
            return true;
#endif
        }

        public override string Name()
        {
            return "Config Center";
        }

        public override Version NeedsApiContainerVersion()
        {
            return new Version("0.0.0.1");
        }

        public override void OnGetDBInstance()
        {

            SystemConfigInfo.InitAllConfigData(GCCLoggerProvider!);
            _ = Task.Factory.StartNew(async () =>
            {
                while (true)
                {
                    await Task.Delay(1000 * 60 * 5);
                    SystemConfigInfo.InitAllConfigData(GCCLoggerProvider!);
                }
            }, TaskCreationOptions.LongRunning);
        }

        public override void OnSystemStarted(AbsGCCContext context)
        {

        }

        public override void SystemTryShutDown()
        {
        }
    }
}
